const express = require("express");
const aiService = require("./aiService");
const app = express();
const port = 3000;

app.use(express.urlencoded({ extended: true, limit: "10mb" }));

app.post("/api/image-recognition", (req, res) => {
  const { base64 } = req.body;
  console.log("/api/image-recognition");
  aiService.recognizeImageContent(base64).then((completion) => {
    console.log(completion.choices[0].message.content);
    res.send({
      msg: completion.choices[0].message.content,
    });
  });
});

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`);
});
